import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace EmployeeApi {
  /** 店员信息 */
  export interface Employee {
    id: number; // 主键
    storeId: number; // 店铺id
    code: string; // 店员编号
    name: string; // 姓名
    gender: number; // 性别
    birthday: string | Dayjs; // 出生日期
    idNumber: string; // 身份证号
    phone: string; // 联系电话
    email: string; // 电子邮箱
    position: number; // 职位
    hireDate: string | Dayjs; // 入职时间
    resignDate: string | Dayjs; // 离职时间
    status?: number; // 上班状态（0在岗 1离休）
  }
}

/** 查询店员分页 */
export function getEmployeePage(params: PageParam) {
  return requestClient.get<PageResult<EmployeeApi.Employee>>('/reservation/employee/page', { params });
}

/** 查询店员详情 */
export function getEmployee(id: number) {
  return requestClient.get<EmployeeApi.Employee>(`/reservation/employee/get?id=${id}`);
}

/** 新增店员 */
export function createEmployee(data: EmployeeApi.Employee) {
  return requestClient.post('/reservation/employee/create', data);
}

/** 修改店员 */
export function updateEmployee(data: EmployeeApi.Employee) {
  return requestClient.put('/reservation/employee/update', data);
}

/** 删除店员 */
export function deleteEmployee(id: number) {
  return requestClient.delete(`/reservation/employee/delete?id=${id}`);
}

/** 导出店员 */
export function exportEmployee(params: any) {
  return requestClient.download('/reservation/employee/export-excel', params);
}

